//
//  MyselfViewController.m
//  ToYourHeartNews
//
//  Created by XJing on 16/1/20.
//  Copyright © 2016年 www.lanou3g.com 蓝鸥. All rights reserved.
//

#import "MyselfViewController.h"
#import "LoginViewController.h"
@interface MyselfViewController ()<UITableViewDataSource, UITableViewDelegate>
@property (nonatomic, strong)UITableView *tableView;
@property (nonatomic, strong)NSArray *dataArr;
@end

@implementation MyselfViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    self.navigationItem.title = @"我的";
    self.navigationItem.leftBarButtonItem = [[UIBarButtonItem alloc]initWithImage:[UIImage imageNamed:@"iconfont-back"] style:UIBarButtonItemStylePlain target:self action:@selector(backAction)];
    //tableView
    self.tableView = [[UITableView alloc]initWithFrame:self.view.frame style:UITableViewStylePlain];
    _tableView.backgroundColor = [UIColor whiteColor];
    [self.view addSubview:_tableView];
    _tableView.dataSource = self;
    _tableView.delegate = self;
    [_tableView registerClass:[UITableViewCell class] forCellReuseIdentifier:@"Mcell"];
    [_tableView release];
    //tableView上面View
    UIView *view = [[UIView alloc]initWithFrame:CGRectMake(0, 0, self.view.frame.size.width, self.view.frame.size.height / 3 )];
    view.backgroundColor = [UIColor grayColor];

    //登陆按钮
    UIButton *person = [UIButton buttonWithType:UIButtonTypeSystem];
    person.frame = CGRectMake(view.frame.size.width / 10 * 4, view.frame.size.height / 6, view.frame.size.width / 5, view.frame.size.width / 5);
    person.layer.cornerRadius = self.view.frame.size.width / 10;
    person.clipsToBounds = YES;
    [person setBackgroundImage:[UIImage imageNamed:@"qiaoba.png"] forState:UIControlStateNormal];
    [person addTarget:self action:@selector(loginAction) forControlEvents:UIControlEventTouchUpInside];
    [view addSubview:person];
    //其他登录方式
    UIView *otherView = [[UIView alloc]initWithFrame:CGRectMake(view.frame.size.width / 3 + 3, person.frame.origin.y + person.frame.size.height + 5, view.frame.size.width / 3, 25)];
    otherView.backgroundColor = [UIColor lightGrayColor];
    UILabel *moreLable = [[UILabel alloc]initWithFrame:CGRectMake(10, 0, otherView.frame.size.width / 7 * 5, 30)];
//    moreLable.backgroundColor = [UIColor redColor];
    moreLable.text = @"更多登录方式";
    moreLable.font = [UIFont systemFontOfSize:14];
    [otherView addSubview:moreLable];
    otherView.layer.cornerRadius = 12;
    otherView.clipsToBounds = YES;
    moreLable.textColor = [UIColor whiteColor];
    [view addSubview:otherView];
    //进入箭头
    UIImageView *goImg = [[UIImageView alloc]initWithFrame:CGRectMake(moreLable.frame.origin.x + moreLable.frame.size.width - 6, moreLable.frame.origin.y, otherView.frame.size.width / 7 * 2, moreLable.frame.size.height - 3)];
    goImg.image = [UIImage imageNamed:@"iconfont-jinru-2"];
    [otherView addSubview:goImg];
    
    _tableView.tableHeaderView = view;
    
    self.dataArr = @[@"离线", @"收藏", @"清除缓存", @"夜间模式"];
}
-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
    return _dataArr.count;
}
-(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
    return 50;
}
-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"Mcell"];
    cell.textLabel.text = _dataArr[indexPath.row];
    cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
    return cell;
}
-(void)loginAction
{
    LoginViewController *login = [[LoginViewController alloc]init];
    [self.navigationController pushViewController:login animated:YES];
    NSLog(@"登录");
}
//返回按钮方法
-(void)backAction
{
    [self dismissViewControllerAnimated:YES completion:^{
        //
    }];
}
- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
